<script setup>
import { onMounted, ref,  } from 'vue'
import {  getUserinfo,register } from '@/api/user/index'
import { useTokenStore } from '@/stores/token'
const tokenStore = useTokenStore()

const uToastRef = ref(null)
const value1 = ref(1)
const passwordValue = ref('')

const accountValue = ref('')
const title = ref('@qq.com')
const notAppMsg = () => {
  uni.showToast({
    title: '请在APP端使用',
    icon: 'none',
    duration: 1500,
  })
  return
}
const rePasswordValue = ref('')
const userRegister = async () => {
 if(!passwordValue.value.length||!accountValue.value.length||!rePasswordValue.value.length){
  uni.showToast({
    title: '参数错误',
    icon: 'none',
    duration: 1500,
  })
  return
 }
 if(passwordValue.value!== rePasswordValue.value){
   uni.showToast({
    title: '两次密码不一致',
    icon: 'none',
    duration: 1500,
   })
   return
 }
  await register(
    {
      userName: accountValue.value,
      password: passwordValue.value,
    },
    rePasswordValue.value
  ).then((res) => {
    if (res.code == 0) {
      uni.showToast({
        title: '注册成功',
        icon: 'none',
        duration: 1000,
      })
      uni.navigateTo({
      url: '/pages/login/index'
    })
    }
  })
}
const gotoLogin = () => {
   uni.navigateTo({
    url:"/pages/login/index"
   })
}
</script>

<template>
  <HeadMenuBar :showHead="false" :showBottom="false" :showTabBar="false">
    <template #default>
      <view class="login_layout">
        <up-toast ref="uToastRef"></up-toast>
        <div class="login">
          <image class="logo" mode="" src="../../../static/logo.png"></image>
          <!--  <h3 class="text-left">
          邮箱注册/登录
        </h3> -->
          <div class="input_sty">
            <up-input type="number" customStyle="font-weight: 400;" class="my_button" confirmType="next" :confirmHold="true" placeholder="请输入账户" border="surround" v-model="accountValue">
              <template #prefix>
                <up-text iconStyle="20px"  prefixIcon="account" margin="-10rpx 0 0 0" type="tips" size="25"></up-text>
              </template>
        
            </up-input>
          </div>
          <div class="input_sty">
            <up-input type="password" v-model="passwordValue" customStyle="font-weight: 400;" placeholder="请输入密码" class="my_button">
              <template #prefix>
                <up-text iconStyle="20px"  prefixIcon="lock" margin="-10rpx 0 0 0" type="tips" size="25"></up-text>
              </template>
            </up-input>
          </div>
          <div class="input_sty">
            <up-input type="password" v-model="rePasswordValue" customStyle="font-weight: 400;" placeholder="请输入重复密码" class="my_button">
              <template #prefix>
                <up-text iconStyle="20px"  prefixIcon="lock" margin="-10rpx 0 0 0" type="tips" size="25"></up-text>
              </template>
            </up-input>
          </div>
          <div class="input_sty">
            <up-button class="my_button logo_color" @click="userRegister()">注册</up-button>
          </div>         
          
          <span @click="gotoLogin()">已有账号去登录</span>
  
        </div>
      </view>
    </template>
  </HeadMenuBar>
</template>

<style lang="scss" scoped>
:deep(.u-icon__icon > span) {
  font-size: 20px;
}

:deep(.u-dropdown__content__popup) {
  border-bottom-right-radius: 20px !important;
  // opacity: 0.9;
  background-color: red !important;
  border-bottom-left-radius: 20px !important;
}

:deep(.u-line) {
  border: 0 !important;
}

:deep(.u-dropdown__menu__item) {
  justify-content: right;
}

:deep(.u-dropdown__content__mask) {
  display: none;
}

.dropdown {
  width: 180rpx !important;
  height: 100% !important;
  padding: 0 0rpx !important;

  .dropdown_item {
    width: 100% !important;
    height: auto !important;
  }
}

.select_style {
  width: 200rpx;
  height: auto;
  border: 0;
  box-shadow: none;
}

.login_layout {
background-color: #f4f4f4;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.login_icon {
  display: flex;
  justify-content: space-between;
  width: 300rpx;
}

.other_login {
  text-align: center;
  position: absolute;
  bottom: 0;
  height: 200rpx;
  width: 600rpx !important;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 12px;
}

.mb30 {
  margin-bottom: 30rpx;
}

.icon {
  width: 70rpx;
  height: 70rpx;
}

.icon:nth-of-type(2) {
  width: 67rpx;
  height: 67rpx;
}



.crice:nth-of-type(2) {
  filter: blur(90px);
  transform: skew(-5deg);
  width: 200px;
  // height: 200px;
  height: 100vh;
  background-color: #d6f9ff;
  position: absolute;
  top: 0px;
  right: -50px;
  border-radius: 150px;
  z-index: 0;
}

* {
  box-sizing: border-box;
}

.yz {
  color: #8eebbe;
  font-size: $nomarl-font-size;
}

.my_button {
  border: 0;
  height: 90rpx !important;
  width: 600rpx !important;
  border-radius: 30rpx !important;
  font-weight: 700;
  background-color: #fff;
  font-size: 400 !important;
}

.logo_color {
  background-color: rgba(5, 196, 107,0.7);
  color: #fff;
}

.text-left {
  width: 100%;
  text-align: left;
  margin-bottom: 50rpx;
}

.input_sty {
  margin-bottom: 40rpx;
}

.group {
  display: flex;
  align-items: center;
  margin-top: 10rpx;
}

.color_b {
  color: black;
}

.service {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.4);
}

.login {
  z-index: 1;
  position: relative;
  margin: auto;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 80rpx 70rpx 0 70rpx;
}

.logo {
  border-radius: 20rpx;
  width: 150rpx;
  height: 150rpx;
  margin-bottom: 150rpx;
  margin-top: 130rpx;
  box-shadow: 0 0 10rpx rgba(0, 0, 0, 0.2);
}
</style>
